package com.douyin.service.impl;

import com.douyin.service.AuditProducerService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AuditProducerServiceImpl implements AuditProducerService {
    @Autowired
    RabbitTemplate rabbitTemplate;

    // 这些值必须和你在网页上创建的完全一样
    private static final String EXCHANGE_NAME = "comment.audit.exchange";
    private static final String ROUTING_KEY = "comment.audit.key";

    public void sendAuditTask(Long commentId) {
        // 你的 Spring 应用会把 commentId 发送到指定的交换机和路由键
        rabbitTemplate.convertAndSend(EXCHANGE_NAME, ROUTING_KEY, String.valueOf(commentId));
        System.out.println("发送审核任务到MQ，评论ID: " + commentId);
    }
}
